#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/12/18 9:47
# @Author  : lizhen
# @Site    : 
# @File    : Chinese.py
# @Software: PyCharm
import os

from PIL import Image
from pytesseract import pytesseract

base_dir = './ext/Chinese/'


class ChineseDemo:
    def captcha(self):
        files = os.listdir(base_dir)
        for item in files:
            im = Image.open(base_dir + item)
            text = pytesseract.image_to_string(im, 'chi_sim')
            print("{{image_name:{},result:{}}}".format(item, text))

    def _test_captcha(self):
        """
        cd = ChineseDemo()
        cd._test_captcha()
        """
        self.captcha()


if __name__ == '__main__':
    cd = ChineseDemo()
    cd._test_captcha()
